{% extends "base.html" %}
{% block content %}

        <!-- /.row -->
        <div class="row">
            <div class="col-lg-6">
                <div class="panel panel-default">
                    <div class="panel-heading" style=" padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; ">

                        <div class="form-group input-group" style=" margin-bottom: 0px; ">
                            <div style="display: teble-cell;color:#555;padding: 7px 12px;"><span>用户: {{ user.username }}</span></div>
                            <span class="input-group-btn">
                                <a href="/admin/del_user/{{ user.username|e }}" onclick="javascript:return confirm('确认要删除此用户?')" style="border-bottom-right-radius: 0;" class="btn btn-danger">删除</a>
                            </span>
                        </div>

                    </div>

                    <!-- /.panel-heading -->
                    <div class="panel-body">

                        {% if err_msg  %}
                            <div class="alert alert-danger alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                {{ err_msg }}
                            </div>
                        {% endif %}
                        <form role="form" action="/admin/change_password/{{ user.username|e }}" method="post">
                            <div class="form-group input-group">
                                <span class="input-group-addon"><i class="fa">用户密码</i></span>
                                <input type="password" class="form-control" name="new_password" placeholder="输入新密码" />
                                <span class="input-group-btn" style="padding-top: 0px;padding-bottom: 0px;">
                                              <button type="submit" class="btn btn-primary" style="text-align:left; width: 117px;">修改密码</button>
                                </span>
                            </div>
                        </form>

                        <form role="form" action="/admin/change_property/active/{% if user.active %}O{% else %}1{% endif %}/{{ user.username|e }}" method="post">

                            <div class="form-group input-group">
                                <span class="input-group-addon"><i style="width: 16px;" class="fa fa-check"></i></span>
                                <input type="text" class="form-control" value="{% if user.active %}O{% else %}X{% endif %}" disabled />
                                <span class="input-group-btn" style="padding-top: 0px;padding-bottom: 0px;">
                                    {% if user.active  %}
                                        <button type="submit" class="btn btn-danger" style="text-align:left; width: 117px;">禁用</button>

                                    {% else %}
                                        <button type="submit" class="btn btn-success" style="text-align:left; width: 117px;">启用</button>

                                    {% endif %}
                                </span>
                            </div>
                        </form>
                        <form role="form" action="/admin/change_property/auto_collect/{% if user.auto_collect %}O{% else %}1{% endif %}/{{ user.username|e }}" method="post">
                            <div class="form-group input-group">
                                <span class="input-group-addon"><i style="width: 16px;" class="fa fa-rmb"></i></span>
                                <input type="text" class="form-control" value="{% if user.auto_collect %}O{% else %}X{% endif %}" disabled />
                                <span class="input-group-btn" style="padding-top: 0px;padding-bottom: 0px;">
                                {% if user.auto_collect  %}
                                    <button type="submit" class="btn btn-danger" style="text-align:left; width: 117px;">取消自动收取</button>
                                {% else %}
                                    <button type="submit" class="btn btn-success" style="text-align:left; width: 117px;">自动收取</button>
                                {% endif %}
                                </span>
                            </div>
                        </form>
                        <form role="form" action="/admin/change_property/is_admin/{% if user.is_admin  %}0 {% else %}1{% endif %}/{{ user.username|e }}" method="post">
                            <div class="form-group input-group">
                                <span class="input-group-addon"><i style="width: 16px;" class="fa fa-wrench"></i></span>
                                <input type="text" class="form-control" value="{% if user.is_admin %}O{% else %}X{% endif %}" disabled />
                                <span class="input-group-btn" style="padding-top: 0px;padding-bottom: 0px;">
                                    {% if user.is_admin  %}
                                        <button type="submit" class="btn btn-danger" style="text-align:left; width: 117px;">取消管理员</button>
                                    {% else %}
                                        <button type="submit" class="btn btn-success" style="text-align:left; width: 117px;">设为管理员</button>
                                    {% endif %}
                                </span>
                            </div>
                        </form>
                        <form role="form" action="/admin/change_user_info/{{ user.username|e }}" method="post">
                            <div class="form-group input-group">
                                            <span class="input-group-addon"><i style="width: 16px;" class="fa fa-group"></i>
                                            </span>
                                <input type="text" class="form-control" name="max_account_no" placeholder="2" value="{{ user.max_account_no|default('2') }}" >
                                            <span class="input-group-addon"><span style="text-align:left; width: 90px; display: inline-block;">迅雷账号限制</span>
                                            </span>
                            </div>
                            <div class="form-group input-group">
                                <span class="input-group-addon"><span style="width: 16px; display: inline-block;">@</span></span>
                                <input type="email" class="form-control" name="email" value="{{ user.email }}" placeholder="crystal@xunlei.com">
                            </div>
                            <button type="submit" class="btn btn-default">提交</button>
                            <a href="/admin/user" class="btn btn-default">返回</a>
                        </form>

                    </div>

                </div>
                <!-- /.panel-body -->
            </div>

        </div>
    <!-- /.col-lg-12 -->
{% endblock %}
{% block navibar %}
    <div class="col-lg-10">
        <h2>用户管理</h2>
        <ol class="breadcrumb">
            <li>
                <a href="/">Home</a>
            </li>
         <li>
                <a href="/admin">Admin</a>
            </li>
            <li class="active">
                <strong>UserManagement</strong>
            </li>
        </ol>
    </div>
{% endblock %}
